//app.js
App({
  data: [

  ],
  navTo: function (e) {
    wx.navigateTo({
      url: e,
    })
  },
  onLaunch: function () {

  },
  radTo: function (e) {
    wx.redirectTo({
      url: e,
    })
  },
  globalData: {
    userInfo: null
  },
  request: function (a) {
    a.data || (a.data = {});
    wx.request({
      url: a.url,
      header: a.header || {
        "content-type": "application/x-www-form-urlencoded"
      },
      data: a.data || {},
      method: a.method || "GET",
      dataType: a.dataType || "json",
      success: function (t) {
        a.success && a.success(t.data);
      },
      fail: function (t) {
        console.warn("--- request fail >>>"), console.warn(t), console.warn("<<< request fail ---");
        wx.showModal({
          title: "网络请求出错",
          content: t.errMsg,
          showCancel: !1,
          success: function (t) {
            t.confirm && a.fail && a.fail(t);
          }
        });
      },
      complete: function (t) {
        200 != t.statusCode && (console.log("--- request http error >>>"), console.log(t.statusCode),
          console.log(t.data), console.log("<<< request http error ---")), a.complete && a.complete(t);
      }
    });
  },
  isLogin: function () {
    var userInfo = wx.getStorageSync("userInfo");
    if (!userInfo) {
      wx.reLaunch({
        url: '../index/index'
      })
    }
  }
})